import requests

import http_utils


class TencentNews:
    """
    腾讯新闻获取类
    """
    URL_DICT = dict()
    URL_DICT["index"] = "https://new.qq.com/ch/tech"  # 腾讯新闻首页

    def collect_index(self):
        """
        获取首页信息
        :return:
        """
        index_url = TencentNews.URL_DICT["index"]
        headers = dict()
        user_agent = http_utils.get_user_agent
        headers["user_agent"] = user_agent

        # 请求获取腾讯新闻首页
        response = requests.get(index_url, headers=headers)
        response.encoding = "gbk"
        if response.status_code == 200:
            print(response.text)
        else:
            print("网络连接出错...")


if __name__ == "__main__":
    tencent = TencentNews()
    tencent.collect_index()
